package com.zhuzi;

import com.zhuzi.utils.ClientUtil;
import org.junit.jupiter.api.Test;

/**
 * @author zhuzi
 * 2022/8/17 16:08
 */
public class SendWs {

    String str82 = "<GATHER_FEEDBACK>\n" +
            "    <AREA_ID>CNCEK070127</AREA_ID>\n" +
            "    <CHNL_NO>%s</CHNL_NO>\n" +
            "    <SESSION_ID></SESSION_ID>\n" +
            "    <RELLIST_TYPE>HJSasRel</RELLIST_TYPE>\n" +
            "    <RELLIST_ID_TYPE></RELLIST_ID_TYPE>\n" +
            "    <RELLIST_ID></RELLIST_ID>\n" +
            "    <FEEDBACK_TIME>2019-12-13T14:25:36.5738892+08:00</FEEDBACK_TIME>\n" +
            "    <CHECK_RESULT>%s</CHECK_RESULT>\n" +
            "    <INSTRUCTION></INSTRUCTION>\n" +
            "    <PROC_ERROR_CODE></PROC_ERROR_CODE>\n" +
            "    <PROC_ERROR_DESCRIPTION>车辆对应的核放单(状态:放行/已出库)数据, 抬杆。</PROC_ERROR_DESCRIPTION>\n" +
            "    <TECH_ERROR_CODE></TECH_ERROR_CODE>\n" +
            "    <TECH_ERROR_DESCRIPTION></TECH_ERROR_DESCRIPTION>\n" +
            "    <IC_INFO>\n" +
            "        <IC_ID></IC_ID>\n" +
            "        <IC_NO>%s</IC_NO>\n" +
            "        <IC_Type></IC_Type>\n" +
            "        <IC_EXTENDED_CONTENT></IC_EXTENDED_CONTENT>\n" +
            "    </IC_INFO>\n" +
            "    <VE_INFO>\n" +
            "        <VE_CUSTOMS_NO></VE_CUSTOMS_NO>\n" +
            "        <VE_LICENSE_NO>蒙E8686</VE_LICENSE_NO>\n" +
            "        <VE_LICENSE_NO2></VE_LICENSE_NO2>\n" +
            "        <DR_CUSTOMS_NO></DR_CUSTOMS_NO>\n" +
            "        <DR_NAME></DR_NAME>\n" +
            "        <TRAILER_ID></TRAILER_ID>\n" +
            "        <WEIGHT_DIFF></WEIGHT_DIFF>\n" +
            "        <CHANNEL_WEIGHT></CHANNEL_WEIGHT>\n" +
            "        <GROSS_WEIGHT></GROSS_WEIGHT>\n" +
            "        <VEHICLE_WEIGHT></VEHICLE_WEIGHT>\n" +
            "    </VE_INFO>\n" +
            "    <CONTA_ID></CONTA_ID>\n" +
            "    <ESEAL_ID></ESEAL_ID>\n" +
            "    <SEAL_ID></SEAL_ID>\n" +
            "    <FORM_INFO>\n" +
            "        <FORM_TYPE></FORM_TYPE>\n" +
            "        <FORM_ID></FORM_ID>\n" +
            "        <MASTER_CUSTOMS_CODE></MASTER_CUSTOMS_CODE>\n" +
            "    </FORM_INFO>\n" +
            "    <PACK_NO></PACK_NO>\n" +
            "    <DECL_PACK></DECL_PACK>\n" +
            "    <DECL_GOODS_WEIGHT></DECL_GOODS_WEIGHT>\n" +
            "    <OP_HINT>车辆对应的核放单(状态:放行/已出库)数据, 抬杆。</OP_HINT>\n" +
            "    <LED_HINT>特殊监管区域放行</LED_HINT>\n" +
            "    <EXTENDED_CONTENT></EXTENDED_CONTENT>\n" +
            "</GATHER_FEEDBACK>";

    @Test
    public void sendUser() throws Exception {
        //http://127.0.0.1:8082/Service/user?wsdl
        String url = "http://127.0.0.1:8082/Service/user?wsdl";

        String result = "";
        try {
            result = ClientUtil.callWebSV(url, "getUserInfo", "CNCEK070127WI04");
        } catch (Exception e) {
            System.err.println("接口调用失败！！！！");
            e.printStackTrace();

        }
        System.out.println("===Finished!===恭喜你啊！！！CatService接口调用成功！！！===获得的数据是：" + result);
    }

    @Test
    public void send81() {
        String url = "http://127.0.0.1:8082/Service/parseXml?wsdl";
        String methodName = "parseSecondTierXml";
        System.out.println("Calling" + url);
        String result = "";
        try {
            result = ClientUtil.callWebSVs(url, methodName, String.format(str82, "CNCEK070127WI04", "Y", "E28011052000795A2F8A097F"), "0x82");
        } catch (Exception e) {
            System.err.println("接口调用失败！！！！");
            e.printStackTrace();

        }
        System.out.println("===Finished!===恭喜你啊！！！CatService接口调用成功！！！===获得的数据是：" + result);
    }

    // TODO 发送82测试
    @Test
    public void send82() {
        String url = "http://127.0.0.1:8182/Service/parseXml?wsdl";
        String methodName = "Receive82Xml";
        System.out.println("Calling" + url);
        String result = "";
        try {
            result = ClientUtil.callWebSV(url, methodName, String.format(str82, "CNCEK070127WI06", "Y", "E28011052000795A2F8A097F"), "0x82");
        } catch (Exception e) {
            System.err.println("接口调用失败！！！！");
            e.printStackTrace();

        }
        System.out.println("===Finished!===恭喜你啊！！！CatService接口调用成功！！！===获得的数据是：" + result);
    }
}
